package com.wanma.recuit.webcontroller;

import com.github.pagehelper.PageInfo;
import com.wanma.recuit.pojo.Collection;
import com.wanma.recuit.pojo.Dictionary;
import com.wanma.recuit.pojo.Industry;
import com.wanma.recuit.pojo.Job;
import com.wanma.recuit.service.CollectionService;
import com.wanma.recuit.service.DictionaryService;
import com.wanma.recuit.service.IndustryService;
import com.wanma.recuit.service.JobService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/service")
public class IndustryController {
    @Resource
    private IndustryService industryService;
    @Resource
    private JobService jobService;
    @Resource
    private CollectionService collectionService;
    @Resource
    private DictionaryService dictionaryService;

    //首页
    @RequestMapping({"/index"})
    public ModelAndView findList(){
        ModelAndView modelAndView = new ModelAndView();
        List<Industry> industries = industryService.findAll();
        modelAndView.addObject("industries",industries);
        List<Job> jobs = jobService.findLatestJob();
        modelAndView.addObject("jobs",jobs);
        List<Collection> collections = collectionService.findHotJob();
        modelAndView.addObject("collections",collections);
        return modelAndView;
    }
    //职位列表
    @RequestMapping({"/list"})
    @ModelAttribute("dictionaries")

    public List<Dictionary> list(){

        return dictionaryService.findList();
    }

    @RequestMapping({"/listdata","/test"})
    @ModelAttribute("pageInfo")
    public PageInfo<Job> listdata(Integer pageNum, Job job){
        System.out.println(pageNum+"------------");
        if(pageNum==null){
            pageNum=1;
        }
        int pageSize=4;
        return jobService.findPage(pageNum,pageSize,job);
    }
//    @RequestMapping({"/list","/test"})
//
//    public ModelAndView list(Integer pageNum, Job job){
//        ModelAndView modelAndView=new ModelAndView();
//        List<Dictionary> dictionaries = dictionaryService.findList();
//        modelAndView.addObject(dictionaries);
//        System.out.println(pageNum+"------------");
//        if(pageNum==null){
//            pageNum=1;
//        }
//        int pageSize=4;
//        PageInfo<Job> pageInfo=jobService.findPage(pageNum,pageSize,job);
//        modelAndView.addObject(pageInfo);
//
//        return modelAndView;
//    }
    //投递简历
    @RequestMapping("/toudi")
    public void toudi(){

    }
    //公司列表
    @RequestMapping("/companylist")
    public void companylist(){

    }
}
